* Apply to: roadmaps_1.dta
* Description:  Table A8 in the OA

clear

set more off


use "...\1805 Roadmaps\roadmaps_1.dta", clear


* Treatment variables

gen con = 0
replace con = 1 if ctr_marlee!=.

gen vgd = 0
replace vgd = 1 if vgd_marlee!=.

gen pty = 0
replace pty = 1 if pty_marlee!=.

gen psi = 0
replace psi = 1 if psi_marlee!=.

gen psp = 0
replace psp = 1 if psp_marlee!=.

gen an3 = 0
replace an3 = 1 if end_marlee!=.
replace an3 = 1 if end_ideo_marlee!=.


gen all_info = 0
replace all_info = 1 if (vgd==1 | pty==1 | psi==1 | psp==1)


* Drop extraneous respondents

drop if an3==1
drop if party=="Other"
drop if (con==0 & vgd==0 & pty==0 & psi==0 & psp==0)
drop end_marlee end_ideo_marlee


* Dependent variables

gen marlee = ctr_marlee
replace marlee = vgd_marlee if vgd==1
replace marlee = pty_marlee if pty==1
replace marlee = psi_marlee if psi==1
replace marlee = psp_marlee if psp==1

gen vote_marlee = 0
replace vote_marlee = 1 if marlee==1
replace vote_marlee = . if marlee==3

gen vote_leemar = 1
replace vote_leemar = 0 if marlee==1
replace vote_leemar = . if marlee==3


gen vote_spatial = 0
replace vote_spatial = 1 if vote_marlee==1 & d1<=0
replace vote_spatial = 1 if vote_marlee==0 & d1>=0
replace vote_spatial = . if vote_marlee==.


* Treatment-Ideology interactins

gen con_D1 = con * d1
gen vgd_D1 = vgd * d1
gen pty_D1 = pty * d1
gen psi_D1 = psi * d1
gen psp_D1 = psp * d1

gen all_info_D1 = all_info * d1


* Demographic variables

gen democrat = 0
replace democrat = 1 if party=="Democrat"

gen chinese = 0
replace chinese = 1 if race==4

gen female = 0
replace female = 1 if gender==2

gen pol_interest2 = 0
replace pol_interest2 = 1 if pol_interest==4
replace pol_interest2 = 2 if pol_interest==3
replace pol_interest2 = 3 if pol_interest==2
replace pol_interest2 = 4 if pol_interest==1
replace pol_interest2 = . if pol_interest==.

gen ret_level2 = 0
replace ret_level2 = 1 if ret_level==4
replace ret_level2 = 2 if ret_level==3
replace ret_level2 = 3 if ret_level==2
replace ret_level2 = 4 if ret_level==1
replace ret_level2 = . if ret_level==.


set more off

*log using "...\1805 Roadmaps\Table A8.log", replace

set seed Xdb5b16bd1bf5b511c933dde5ad30af0900042cdf


probit vote_leemar ///
     vgd vgd_D1 ///
     pty pty_D1 ///
     psi psi_D1 ///
     psp psp_D1 ///
     d1

tabstat d1 if e(sample), s(n mean sd min p25 p50 p75 max)


estsimp probit vote_leemar ///
     vgd vgd_D1 ///
     pty pty_D1 ///
     psi psi_D1 ///
     psp psp_D1 ///
     d1


setx median
simqi, pr listx

simqi, fd(prval(1) genpr(fd_con)) changex(d1 .017 1.021)


setx d1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_vgd_con)) changex(vgd 0 1)
simqi, fd(prval(1) genpr(tr_pty_con)) changex(pty 0 1)
simqi, fd(prval(1) genpr(tr_psi_con)) changex(psi 0 1)
simqi, fd(prval(1) genpr(tr_psp_con)) changex(psp 0 1)


setx median
setx vgd 1
setx vgd_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_vgd)) changex(d1 .017 1.021 vgd_D1 .017 1.021)


setx d1 0
setx vgd_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_pty_vgd)) changex(vgd 1 0 pty 0 1)
simqi, fd(prval(1) genpr(tr_psi_vgd)) changex(vgd 1 0 psi 0 1)
simqi, fd(prval(1) genpr(tr_psp_vgd)) changex(vgd 1 0 psp 0 1)


setx median
setx pty 1
setx pty_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_pty)) changex(d1 .017 1.021 pty_D1 .017 1.021)


setx d1 0
setx pty_D1 0
simqi, pr listx


setx median
setx psi 1
setx psi_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_psi)) changex(d1 .017 1.021 psi_D1 .017 1.021)


setx d1 0
setx psi_D1 0
simqi, pr listx


setx median
setx psp 1
setx psp_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_psp)) changex(d1 .017 1.021 psp_D1 .017 1.021)


setx d1 0
setx psp_D1 0
simqi, pr listx


* Difference in baseline probabilities

tabstat tr_vgd_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_pty_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psi_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psp_con, s(mean sd min p5 p10 p50 p90 p95 max)


tabstat tr_pty_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psi_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psp_vgd, s(mean sd min p5 p10 p50 p90 p95 max)


* Calculate difference in first differences

gen dif_vgd_con = fd_vgd - fd_con
gen dif_pty_con = fd_pty - fd_con
gen dif_psi_con = fd_psi - fd_con
gen dif_psp_con = fd_psp - fd_con

tabstat dif_vgd_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_pty_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psi_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psp_con, s(mean sd min p5 p10 p50 p90 p95 max)


gen dif_pty_vgd = fd_pty - fd_vgd
gen dif_psi_vgd = fd_psi - fd_vgd
gen dif_psp_vgd = fd_psp - fd_vgd

tabstat dif_pty_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psi_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psp_vgd, s(mean sd min p5 p10 p50 p90 p95 max)


drop b1-b10
drop fd_con-dif_psp_vgd

*log close


set more off

*log using "...\1805 Roadmaps\Table A8 demo.log", replace

set seed X301a72cdc0cc277d6a1d73b5959503bc0004141c


probit vote_leemar ///
     vgd vgd_D1 ///
     pty pty_D1 ///
     psi psi_D1 ///
     psp psp_D1 ///
     d1 female inc_level pol_interest2 ret_level2

tabstat d1 if e(sample), s(n mean sd min p25 p50 p75 max)
tabstat inc_level if e(sample), s(n mean sd min p25 p50 p75 max)
tabstat pol_interest2 if e(sample), s(n mean sd min p25 p50 p75 max)
tabstat ret_level2 if e(sample), s(n mean sd min p25 p50 p75 max)


estsimp probit vote_leemar ///
     vgd vgd_D1 ///
     pty pty_D1 ///
     psi psi_D1 ///
     psp psp_D1 ///
     d1 female pol_interest2 ret_level2 inc_level


setx median
simqi, pr listx

simqi, fd(prval(1) genpr(fd_con)) changex(d1 .017 1.021)

simqi, fd(prval(1) genpr(fd_fem)) changex(female 0 1)
simqi, fd(prval(1) genpr(fd_inc)) changex(inc_level 2 5)
simqi, fd(prval(1) genpr(fd_int)) changex(pol_interest2 3 4)
simqi, fd(prval(1) genpr(fd_ret)) changex(ret_level2 2 3)


setx d1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_vgd_con)) changex(vgd 0 1)
simqi, fd(prval(1) genpr(tr_pty_con)) changex(pty 0 1)
simqi, fd(prval(1) genpr(tr_psi_con)) changex(psi 0 1)
simqi, fd(prval(1) genpr(tr_psp_con)) changex(psp 0 1)


setx median
setx vgd 1
setx vgd_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_vgd)) changex(d1 .017 1.021 vgd_D1 .017 1.021)


setx d1 0
setx vgd_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_pty_vgd)) changex(vgd 1 0 pty 0 1)
simqi, fd(prval(1) genpr(tr_psi_vgd)) changex(vgd 1 0 psi 0 1)
simqi, fd(prval(1) genpr(tr_psp_vgd)) changex(vgd 1 0 psp 0 1)


setx median
setx pty 1
setx pty_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_pty)) changex(d1 .017 1.021 pty_D1 .017 1.021)


setx d1 0
setx pty_D1 0
simqi, pr listx


setx median
setx psi 1
setx psi_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_psi)) changex(d1 .017 1.021 psi_D1 .017 1.021)


setx d1 0
setx psi_D1 0
simqi, pr listx


setx median
setx psp 1
setx psp_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_psp)) changex(d1 .017 1.021 psp_D1 .017 1.021)


setx d1 0
setx psp_D1 0
simqi, pr listx


* Difference in baseline probabilities

tabstat tr_vgd_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_pty_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psi_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psp_con, s(mean sd min p5 p10 p50 p90 p95 max)


tabstat tr_pty_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psi_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psp_vgd, s(mean sd min p5 p10 p50 p90 p95 max)


* Calculate difference in first differences

gen dif_vgd_con = fd_vgd - fd_con
gen dif_pty_con = fd_pty - fd_con
gen dif_psi_con = fd_psi - fd_con
gen dif_psp_con = fd_psp - fd_con

tabstat dif_vgd_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_pty_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psi_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psp_con, s(mean sd min p5 p10 p50 p90 p95 max)


gen dif_pty_vgd = fd_pty - fd_vgd
gen dif_psi_vgd = fd_psi - fd_vgd
gen dif_psp_vgd = fd_psp - fd_vgd

tabstat dif_pty_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psi_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psp_vgd, s(mean sd min p5 p10 p50 p90 p95 max)


drop b1-b14
drop fd_con-dif_psp_vgd

*log close


set more off

*log using "...\1805 Roadmaps\Table A8 any info.log", replace

set seed X74eb8d3d2a170360c16003ffac21a9f700040757


probit vote_leemar ///
     all_info all_info_D1 ///
     d1

tabstat d1 if e(sample), s(n mean sd min p25 p50 p75 max)


estsimp probit vote_leemar ///
     all_info all_info_D1 ///
     d1


setx median
setx d1 .448
setx all_info 0
setx all_info_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(fd_con)) changex(d1 .017 1.021)


setx d1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_all_info_con)) changex(all_info 0 1)


setx median
setx all_info 1
setx all_info_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_all_info)) changex(d1 .017 1.021 all_info_D1 .017 1.021)


setx d1 0
setx all_info_D1 0
simqi, pr listx


* Difference in baseline probabilities

tabstat tr_all_info_con, s(mean sd min p5 p10 p50 p90 p95 max)


* Calculate difference in first differences

gen dif_all_info_con = fd_all_info - fd_con

tabstat dif_all_info_con, s(mean sd min p5 p10 p50 p90 p95 max)


drop b1-b4
drop fd_con-dif_all_info_con

*log close


set more off

*log using "...\1805 Roadmaps\Table A8 any info demo.log", replace

set seed Xf31a93d5f6d3127fe027dfd2b01988e4000420dd


probit vote_leemar ///
     all_info all_info_D1 ///
     d1 female inc_level pol_interest2 ret_level2

tabstat d1 if e(sample), s(n mean sd min p25 p50 p75 max)
tabstat inc_level if e(sample), s(n mean sd min p25 p50 p75 max)
tabstat pol_interest2 if e(sample), s(n mean sd min p25 p50 p75 max)
tabstat ret_level2 if e(sample), s(n mean sd min p25 p50 p75 max)


estsimp probit vote_leemar ///
     all_info all_info_D1 ///
     d1 female inc_level pol_interest2 ret_level2


setx median
setx d1 .448
setx all_info 0
setx all_info_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(fd_con)) changex(d1 .017 1.021)

simqi, fd(prval(1) genpr(fd_fem)) changex(female 0 1)
simqi, fd(prval(1) genpr(fd_inc)) changex(inc_level 2 5)
simqi, fd(prval(1) genpr(fd_int)) changex(pol_interest2 3 4)
simqi, fd(prval(1) genpr(fd_ret)) changex(ret_level2 2 3)


setx d1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_all_info_con)) changex(all_info 0 1)


setx median
setx all_info 1
setx all_info_D1 .448
simqi, pr listx

simqi, fd(prval(1) genpr(fd_all_info)) changex(d1 .017 1.021 all_info_D1 .017 1.021)


setx d1 0
setx all_info_D1 0
simqi, pr listx


* Difference in baseline probabilities

tabstat tr_all_info_con, s(mean sd min p5 p10 p50 p90 p95 max)


* Calculate difference in first differences

gen dif_all_info_con = fd_all_info - fd_con

tabstat dif_all_info_con, s(mean sd min p5 p10 p50 p90 p95 max)


drop b1-b8
drop fd_con-dif_all_info_con

*log close

* End
